﻿using System.Collections.Generic;
using INTEX.DataBase.Tools;
using ReflectionStudio.Core.Events;
using System;
using System.Collections;
using System.Data;
using System.Linq;

namespace WPFExcelReport
{
    public partial class ITXEXRPT
    {

        /// <summary>
        /// GetJob is used to collect the tasks to finish the order creation
        /// </summary>
        /// <param name="FInterID"></param>
        /// <returns></returns>
        public void UFSCHK(DataSet db)
        {
            try
            {


                DataTable tbWBBST = db.Tables["ICC_STOCK"];
                DataTable dtOutput = new DataTable();
                int idx = 1;
                int x = 3;
                #region======Title===========
                exAgent.SetCellValue(x, idx++, "时间区间"); dtOutput.Columns.Add("TIMERANGE", typeof(System.String)); 
                exAgent.SetCellValue(x, idx++, "品种"); dtOutput.Columns.Add("CINVCODE", typeof(System.String));
                exAgent.SetCellValue(x, idx++, "品名"); dtOutput.Columns.Add("CINVSTD", typeof(System.String));
                exAgent.SetCellValue(x, idx++, "卷号"); dtOutput.Columns.Add("BARCODE", typeof(System.String)); 
                exAgent.SetCellValue(x, idx++, "米数"); dtOutput.Columns.Add("QTY", typeof(System.String));
                exAgent.SetCellValue(x, idx++, "件数"); dtOutput.Columns.Add("WBBZMT", typeof(System.String));
                exAgent.SetCellValue(x, idx++, "批号"); dtOutput.Columns.Add("PLOT", typeof(System.String));
                exAgent.SetCellValue(x, idx++, "工号"); dtOutput.Columns.Add("EMPLOYID", typeof(System.String));
                exAgent.SetCellValue(x, idx++, "机台号"); dtOutput.Columns.Add("MACHNO", typeof(System.String)); 
                #endregion
                dtOutput.Merge(tbWBBST, false, MissingSchemaAction.Ignore);
                string title = ""; string room = "";
                foreach (DataRow row in dtOutput.Rows)
                {
                    title = "UFS核对" + row["TIMERANGE"].ToString(); 
                }
                exAgent.DataTableToExcel(dtOutput, x + 1, 1);
                exAgent.SetCellValue(1, 1, 1);
                int count = dtOutput.Rows.Count;
                exAgent.BatchConvert2Number(x + 1, 7, count + x + 1, 8);
                exAgent.SetCellValue(1, 2, title);
            }
            catch (Exception ex)
            {
                Tracer.Error(ex.StackTrace, ex);
            }

        }

    }
}
